package com.design.structural.Bridge.Thermometer.Thermometer;

import com.design.structural.Bridge.Thermometer.Weather_API.globalAPI;
import com.design.structural.Bridge.Thermometer.Weather_API.juheAPI;
import com.design.structural.Bridge.Thermometer.Weather_API.weatherAPI;
import com.design.structural.Bridge.Thermometer.Weather_API.xinzhiAPI;

/**
 * 描述: 文字风格温度计
 *
 * @author YuJunJie
 * @create 2019-04-04 11:04
 */
public class TextThermometer implements Thermometer{

    private weatherAPI api;
    private String apiName;

    @Override
    public void setWeatherAPI(weatherAPI api, String apiName) {
        this.api = api;
        this.apiName = apiName;
    }

    @Override
    public void show(String cityName) {
        if (api == null){
            weatherAPI temp = new juheAPI();
            System.out.println("\"\"\"聚合数据api\"\"\"");
            System.out.println(temp.getWeatherInfo(cityName));
            temp = new xinzhiAPI();
            System.out.println("\"\"\"心知天气api\"\"\"");
            System.out.println(temp.getWeatherInfo(cityName));
            temp = new globalAPI();
            System.out.println("\"\"\"全球天气数据api\"\"\"");
            System.out.println(temp.getWeatherInfo(cityName));
        }
        else{
            System.out.println(api.getWeatherInfo(cityName));
        }
    }
}
